package 题目集.dfs;

import java.util.Scanner;

public class 四平方和定理 {
    static int[] path = new int[5];

    public static boolean dfs(int n, int i) {
        if (n == 0) {
            return true;
        }
        if (i > 4 || n < 0) {
            return false;
        }
        int p = (int) Math.sqrt(n);
        for (int j = path[i-1]; j <= p; j++) {
            path[i] = j;
            if (dfs(n - j * j, i + 1)) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        dfs(n, 1);
        for (int i = 1; i <= 4; i++) {
            System.out.print(path[i] + " ");
        }
    }
}
